<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="车辆VIN号:" prop="vin">
          <el-input v-model="formModel.vin" clearable/>
        </el-form-item>
        <el-form-item class="no-warn-item" label="一致性证书编号:" prop="consistencyCertificateNo">
          <el-input v-model="formModel.consistencyCertificateNo" clearable/>
        </el-form-item>
        <el-form-item class="no-warn-item" label="上传状态:" prop="uploadStatus">
          <hey-select v-model="formModel.uploadStatus" clcd="upload_status_cd" />
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button type="primary" v-if="hasPermission('consistency_certificate_upload_select')" plain @click="queryList">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :columns="columns" :is-select="false">
      <template slot="tools">
        <el-table-column
          label="操作"
          width="80"
          fixed="right"
          header-align="center"
          align="center"
        >
          <template slot-scope="{row}">
            <span class="hey_tools_btn" v-if="hasPermission('consistency_certificate_upload_confirm')" @click="handleUpload(row)">上传</span>
          </template>
        </el-table-column>
      </template>
    </hey-table>

  </div>
</template>

<script>
  export default {
    name: 'UploadList',
    components: {

    },
    props: {},
    data() {
      return {
        formModel: {
          vin: '',
          consistencyCertificateNo: '',
          uploadStatus: '',
        },
        columns: [
          { title: '证书编号', key: 'consistencyCertificateNo' },
          { title: '车辆VIN号', key: 'vin' },
          { title: '发动机编号', key: 'keypartNo'},
          { title: '车身颜色', key: 'clys'},
          { title: '车辆制造日期', key: 'storageTime' },
          { title: '打印日期', key: 'printTime' },
          { title: '上传状态', key: 'uploadStatus',clcd:'upload_status_cd' },
          { title: '上传日期', key: 'uploadTime' },
        ]
      }
    },
    computed: {},
    mounted() {

    },
    methods: {
      queryList() {
        this.$refs.table.query('/qualityCertificatePrint/queryUpload', this.formModel, '', false)
      },
      handleUpload(row) {
        if (!row.printTime) {
          this.$warn('该车辆还未进行证书打印,不能进行上传操作!')
          return false
        }
        if (row.uploadTime) {
          this.$warn('该车辆已上传证书,不能重复上传!')
          return false
        }
        this.post('/qualityCertificatePrint/upload', { vin: row.vin}).then(_ => {
          this.$info('上传成功', this.queryList)
        })
      },
    }
  }
</script>

<style lang="scss" scoped>

</style>
